package com.qf.consumer.listeners;

import org.apache.kafka.clients.consumer.ConsumerRecord;
import org.springframework.kafka.annotation.KafkaListener;
import org.springframework.stereotype.Component;

import javax.swing.text.Position;

@Component
public class KafkaConsumer {

    @KafkaListener(groupId = "group1",topics = "test1")
    public void consume(ConsumerRecord record){
        int partition = record.partition();
        //key和value都是String，因为我们设定的key-value序列化器是StringSerializer
        Object key = record.key();
        Object value = record.value();
        long offset = record.offset();

        System.out.println("partition:" + partition);
        System.out.println("key:" + key);
        System.out.println("value:" + value);
        System.out.println("offset:" + offset);
        System.out.println("------------------------");
    }
}
